import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;


public class NameGUI extends JFrame {

	private JPanel contentPane;
	public JTextField Player1Field;
	public JTextField Player2Field;
	public JTextField Player3Field;
	public JTextField Player4Field;
	public JTextField PlayerTab[] = new JTextField[4];
	public JLabel label,label_1,label_2,label_3;
	public JLabel labelTab[] = new JLabel[4];
	private Table t;
	
	NameGUI(Table t, int humNum) {
		
		this.t = t;
		setTitle("Poker - Players Names");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(500, 250, 300, 250);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JLabel FillPlayersNamesLabel = new JLabel("Fill Players Names");
		FillPlayersNamesLabel.setFont(new Font("Tahoma", Font.PLAIN, 20));
		FillPlayersNamesLabel.setBounds(56, 11, 171, 25);
		contentPane.add(FillPlayersNamesLabel);
		
		label = new JLabel("1.");
		label.setEnabled(false);
		label.setFont(new Font("Tahoma", Font.PLAIN, 15));
		label.setBounds(68, 63, 16, 13);
		contentPane.add(label);
		
		label_1 = new JLabel("2.");
		label_1.setEnabled(false);
		label_1.setFont(new Font("Tahoma", Font.PLAIN, 15));
		label_1.setBounds(68, 87, 16, 13);
		contentPane.add(label_1);
		
		label_2 = new JLabel("3.");
		label_2.setEnabled(false);
		label_2.setFont(new Font("Tahoma", Font.PLAIN, 15));
		label_2.setBounds(68, 111, 16, 13);
		contentPane.add(label_2);
		
		label_3 = new JLabel("4.");
		label_3.setEnabled(false);
		label_3.setFont(new Font("Tahoma", Font.PLAIN, 15));
		label_3.setBounds(68, 135, 16, 13);
		contentPane.add(label_3);
		
		this.Player1Field = new JTextField();
		Player1Field.setEnabled(false);
		Player1Field.setBounds(86, 61, 114, 20);
		contentPane.add(Player1Field);
		Player1Field.setColumns(10);
		
		Player2Field = new JTextField();
		Player2Field.setEnabled(false);
		Player2Field.setBounds(86, 85, 114, 20);
		contentPane.add(Player2Field);
		Player2Field.setColumns(10);
		
		Player3Field = new JTextField();
		Player3Field.setEnabled(false);
		Player3Field.setBounds(86, 109, 114, 20);
		contentPane.add(Player3Field);
		Player3Field.setColumns(10);
		
		Player4Field = new JTextField();
		Player4Field.setEnabled(false);
		Player4Field.setBounds(86, 133, 114, 20);
		contentPane.add(Player4Field);
		Player4Field.setColumns(10);
		
		JButton OkButton = new JButton("OK");
		OkButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				setVisible(false);
				notifyTable();
			}
		});
		OkButton.setBounds(96, 164, 89, 23);
		contentPane.add(OkButton);
		
		PlayerTab[0] = Player1Field;
		PlayerTab[1] = Player2Field;
		PlayerTab[2] = Player3Field;
		PlayerTab[3] = Player4Field;
		
		labelTab[0] = label;
		labelTab[1] = label_1;
		labelTab[2] = label_2;
		labelTab[3] = label_3;
		
		for(int i=0;i<humNum;i++) {
			PlayerTab[i].setEnabled(true);
			labelTab[i].setEnabled(true);
		}
	}
	
	public synchronized void notifyTable() {
		
		t.notifier();
	}

}
